<!--
 * @Date: 2023-05-05 20:42:52
 * @LastEditors: xu-kangshuai kangshuai811@163.com
 * @LastEditTime: 2023-05-05 22:13:37
 * @FilePath: \zy-day05\src\App.vue
-->
<!--
 * @Date: 2023-05-05 20:42:52
 * @LastEditors: xu-kangshuai kangshuai811@163.com
 * @LastEditTime: 2023-05-05 22:13:25
 * @FilePath: \zy-day05\src\App.vue
-->
<template>
  <div>
    <form @submit.prevent="diagnose">
      <label>姓名：</label>
      <input type="text" v-model="name"><br><br>

      <label>年龄：</label>
      <input type="number" v-model="age"><br><br>

      <label>身高：</label>
      <input type="number" v-model="height">(米)<br><br>

      <label>体重：</label>
      <input type="number" v-model="weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text" v-model="history"><br><br>

      <button type="submit">诊断</button>
    </form>

    <p>患者 {{ name }} 的诊断结果：{{ result }}</p>
  </div>
</template>

<script>
export default {
  data () {
    return {
      name: '',
      age: 0,
      height: 0,
      weight: 0,
      history: '',
      result: ''
    }
  },
  methods: {
    diagnose () {
      const bmi = this.weight / (this.height * this.height);
      if (bmi >= 18.5 && bmi <= 24.9) {
        this.result = '健康';
      } else {
        this.result = '不健康';
      }
    }
  }
}
</script>
